package com.csun.cmny.provider.controller;

import com.csun.cmny.core.support.BaseController;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.OmcPointCardAccountService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/pointCardAccount", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class OmcPointCardAccountController extends BaseController {

    @Resource
    private CmnyMessageSource cmnyMessageSource;
    @Resource
    private OmcPointCardAccountService omcPointCardAccountService;

    /**
     * 一卡通管理-冻结
     *
     * @param deviceId
     * @return the wrapper
     */
    @RequestMapping(value = "/freeze/{deviceId}", method = RequestMethod.POST)
    public Wrapper freeze(@PathVariable Long deviceId) {
        int i = omcPointCardAccountService.freeze(deviceId);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),i);
    }

    /**
     * 一卡通管理-解冻
     *
     * @param deviceId
     * @return the wrapper
     */
    @RequestMapping(value = "/unfreeze/{deviceId}", method = RequestMethod.POST)
    public Wrapper unfreeze(@PathVariable Long deviceId) {
        int i = omcPointCardAccountService.unfreeze(deviceId);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),i);
    }

    /**
     * 一卡通管理-退卡
     *
     * @param deviceId
     * @return the wrapper
     */
    @RequestMapping(value = "/refund/{deviceId}", method = RequestMethod.POST)
    public Wrapper refund(@PathVariable Long deviceId) {
        int i = omcPointCardAccountService.refund(deviceId);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),i);
    }

    /**
     * 一卡通管理-补办新卡
     *
     * @param deviceId
     * @return the wrapper
     */
    @RequestMapping(value = "/reissue/{deviceId}", method = RequestMethod.POST)
    public Wrapper reissue(@PathVariable Long deviceId) {
//        int i = dmcPointCardBindService.reissue(deviceId);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),null);
    }

}
